﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DOTNETGROUP.Entities;
using DOTNETGROUP.Data;

public partial class Controls_ControlKhoaHocContent : System.Web.UI.UserControl
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Pager1.CurrentIndex = 1;
            Bind_Data1(Pager1.CurrentIndex);
            Pager2.CurrentIndex = 1;
            Bind_Data2(Pager2.CurrentIndex);
            Pager3.CurrentIndex = 1;
            Bind_Data3(Pager3.CurrentIndex);
            Pager4.CurrentIndex = 1;
            Bind_Data4(Pager4.CurrentIndex);
            Pager5.CurrentIndex = 1;
            Bind_Data5(Pager5.CurrentIndex);
        }
    }
//--------------------------
    protected void Bind_Data1(int PageNo)
    {
        int TotalRows = 0;
        string WhereClause = "IdLoaiKhoaHoc=1";
        TList<KhoaHoc> TList_KhoaHoc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "", PageNo - 1, Pager1.PageSize, out TotalRows);
        dlkhoahoc1.DataSource = TList_KhoaHoc;
        dlkhoahoc1.DataBind();
        Pager1.ItemCount = TotalRows;
        H_PageCount.Value = Pager1.PageCount.ToString();
    }
    protected void Pager1_Command(object sender, CommandEventArgs e)
    {
        try
        {
            int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
            Pager1.CurrentIndex = currnetPageIndex;
            Bind_Data1(Pager1.CurrentIndex);
        }
        catch (Exception ex)
        {
            Common.WriteLog("QLHinhAnh.aspx.cs", "Pager1_Command()", ex.ToString());
        }
    }
    protected void cmdPrevious_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager1.CurrentIndex > 1)
        {
            Pager1.CurrentIndex = Pager1.CurrentIndex - 1;
            Bind_Data1(Pager1.CurrentIndex);
        }
    }
    protected void cmdNext_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager1.CurrentIndex < Convert.ToInt32(H_PageCount.Value))
        {
            Pager1.CurrentIndex = Pager1.CurrentIndex + 1;
            Bind_Data1(Pager1.CurrentIndex);
        }
    }
    //--------------------------------
    protected void Bind_Data2(int PageNo)
    {
        int TotalRows = 0;
        string WhereClause = "IdLoaiKhoaHoc=2";
        TList<KhoaHoc> TList_KhoaHoc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "", PageNo - 1, Pager2.PageSize, out TotalRows);
        dlkhoahoc2.DataSource = TList_KhoaHoc;
        dlkhoahoc2.DataBind();
        Pager2.ItemCount = TotalRows;
        H_PageCount2.Value = Pager2.PageCount.ToString();
    }
    protected void Pager2_Command(object sender, CommandEventArgs e)
    {
        try
        {
            int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
            Pager2.CurrentIndex = currnetPageIndex;
            Bind_Data2(Pager2.CurrentIndex);
        }
        catch (Exception ex)
        {
            Common.WriteLog("QLHinhAnh.aspx.cs", "Pager2_Command()", ex.ToString());
        }
    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager2.CurrentIndex > 1)
        {
            Pager2.CurrentIndex = Pager2.CurrentIndex - 1;
            Bind_Data2(Pager2.CurrentIndex);
        }

    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager2.CurrentIndex < Convert.ToInt32(H_PageCount2.Value))
        {
            Pager2.CurrentIndex = Pager2.CurrentIndex + 1;
            Bind_Data2(Pager2.CurrentIndex);
        }
    }
    //---------------------
    protected void Bind_Data3(int PageNo)
    {
        int TotalRows = 0;
        string WhereClause = "IdLoaiKhoaHoc=3";
        TList<KhoaHoc> TList_KhoaHoc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "", PageNo - 1, Pager3.PageSize, out TotalRows);
        dlkhoahoc3.DataSource = TList_KhoaHoc;
        dlkhoahoc3.DataBind();
        Pager3.ItemCount = TotalRows;
        H_PageCount3.Value = Pager3.PageCount.ToString();
    }
    protected void Pager3_Command(object sender, CommandEventArgs e)
    {
        try
        {
            int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
            Pager3.CurrentIndex = currnetPageIndex;
            Bind_Data3(Pager3.CurrentIndex);
        }
        catch (Exception ex)
        {
            Common.WriteLog("QLHinhAnh.aspx.cs", "Pager3_Command()", ex.ToString());
        }
    }

    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager3.CurrentIndex > 1)
        {
            Pager3.CurrentIndex = Pager3.CurrentIndex - 1;
            Bind_Data3(Pager3.CurrentIndex);
        }

    }
    protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager3.CurrentIndex < Convert.ToInt32(H_PageCount3.Value))
        {
            Pager3.CurrentIndex = Pager3.CurrentIndex + 1;
            Bind_Data3(Pager3.CurrentIndex);
        }
    }

    //---------------------
    protected void Bind_Data4(int PageNo)
    {
        int TotalRows = 0;
        string WhereClause = "IdLoaiKhoaHoc=4";
        TList<KhoaHoc> TList_KhoaHoc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "", PageNo - 1, Pager4.PageSize, out TotalRows);
        dlkhoahoc4.DataSource = TList_KhoaHoc;
        dlkhoahoc4.DataBind();
        Pager4.ItemCount = TotalRows;
        H_PageCount4.Value = Pager4.PageCount.ToString();
    }
    protected void Pager4_Command(object sender, CommandEventArgs e)
    {
        try
        {
            int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
            Pager4.CurrentIndex = currnetPageIndex;
            Bind_Data4(Pager4.CurrentIndex);
        }
        catch (Exception ex)
        {
            Common.WriteLog("QLHinhAnh.aspx.cs", "Pager4_Command()", ex.ToString());
        }
    }



    protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager4.CurrentIndex > 1)
        {
            Pager4.CurrentIndex = Pager4.CurrentIndex - 1;
            Bind_Data4(Pager4.CurrentIndex);
        }

    }
    protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager4.CurrentIndex < Convert.ToInt32(H_PageCount4.Value))
        {
            Pager4.CurrentIndex = Pager4.CurrentIndex + 1;
            Bind_Data4(Pager4.CurrentIndex);
        }
    }

    //---------------------
    protected void Bind_Data5(int PageNo)
    {
        int TotalRows = 0;
        string WhereClause = "IdLoaiKhoaHoc=5";
        TList<KhoaHoc> TList_KhoaHoc = DataRepository.KhoaHocProvider.GetPaged(WhereClause, "", PageNo - 1, Pager5.PageSize, out TotalRows);
        dlkhoahoc5.DataSource = TList_KhoaHoc;
        dlkhoahoc5.DataBind();
        Pager5.ItemCount = TotalRows;
        H_PageCount5.Value = Pager5.PageCount.ToString();
    }

    protected void Pager5_Command(object sender, CommandEventArgs e)
    {
        try
        {
            int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
            Pager5.CurrentIndex = currnetPageIndex;
            Bind_Data5(Pager5.CurrentIndex);
        }
        catch (Exception ex)
        {
            Common.WriteLog("QLHinhAnh.aspx.cs", "Pager4_Command()", ex.ToString());
        }
    }

    protected void ImageButton7_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager5.CurrentIndex > 1)
        {
            Pager5.CurrentIndex = Pager5.CurrentIndex - 1;
            Bind_Data5(Pager5.CurrentIndex);
        }

    }
    protected void ImageButton8_Click(object sender, ImageClickEventArgs e)
    {
        if (Pager5.CurrentIndex < Convert.ToInt32(H_PageCount5.Value))
        {
            Pager5.CurrentIndex = Pager5.CurrentIndex + 1;
            Bind_Data5(Pager5.CurrentIndex);
        }
    }


    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}
